﻿<UserControl x:Class="navigation.Controls.TaskListControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:s="http://schemas.microsoft.com/surface/2008"
             mc:Ignorable="d" 
             x:Name="tasksList"
             d:DesignHeight="200" d:DesignWidth="290">
    <UserControl.Resources>

        <!--<Image x:Key="Adam" Source="\Resources\Avatars\Adore.png" Stretch="Uniform"/>
        <Image x:Key="Charls" Source="\Resources\Avatars\Cool.png" Stretch="Uniform"/>
        <Image x:Key="Cindy" Source="\Resources\Avatars\Cry.png" Stretch="Uniform"/>
        <Image x:Key="Frank" Source="\Resources\Avatars\Furious.png" Stretch="Uniform"/>
        <Image x:Key="Laura" Source="\Resources\Avatars\Laugh.png" Stretch="Uniform"/>
        <Image x:Key="Peter" Source="\Resources\Avatars\Pudently.png" Stretch="Uniform"/>
        <Image x:Key="Steve" Source="\Resources\Avatars\Struggle.png" Stretch="Uniform"/>
        <Image x:Key="Sam" Source="\Resources\Avatars\Study.png" Stretch="Uniform"/>
        <Image x:Key="Serena" Source="\Resources\Avatars\Sweet-angel.png" Stretch="Uniform"/>-->
        
        <DataTemplate x:Key="TaskListItemDataTemplate">
            <Border BorderThickness="4">
                <StackPanel Height="20" Orientation="Horizontal">
                    <Image Source="/Resources/Avatars/Study.png" Stretch="Uniform" Margin="5,0,5,0"/>
                    <TextBlock Text="{Binding TaskName}" Height="Auto" FontSize="13" FontFamily="Arial" Foreground="Black" VerticalAlignment="Bottom" TextAlignment="Right"/>
                </StackPanel>
                <Border.Resources>
                    <Style TargetType="{x:Type Border}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding State}" Value="Planned">
                                <Setter Property="BorderBrush" Value="Red"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding State}" Value="InProgress">
                                <Setter Property="BorderBrush" Value="Yellow"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding State}" Value="Done">
                                <Setter Property="BorderBrush" Value="LightGreen"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Resources>
            </Border>
        </DataTemplate>

        <Style x:Key="CursorStyle" TargetType="{x:Type ContentControl}">
            <Setter Property="ContentTemplate" Value="{StaticResource TaskListItemDataTemplate}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ContentControl}">
                        <Border BorderBrush="White" BorderThickness="1">
                            <ContentPresenter
                                Content="{TemplateBinding Content}" 
                                ContentTemplate="{TemplateBinding ContentTemplate}">
                            </ContentPresenter>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="ListBoxItem" x:Key="ContainerStyle">
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">                       
                        <ContentPresenter/>                        
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
    </UserControl.Resources>
    
    <Grid Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="0" Text="   Tasks List" FontSize="15" FontFamily="Arial" FontStyle="Italic" Foreground="Black" Width="290"/>
        <s:SurfaceListBox Grid.Row="1" Name="TaskListBox" Background="Transparent" BorderBrush="{DynamicResource {x:Static s:SurfaceColors.ListBoxItemBackgroundBrushKey}}" BorderThickness="2" ItemContainerStyle="{StaticResource ContainerStyle}"                          
                          ItemsSource="{Binding ElementName=tasksList, Path=TaskList}" ItemTemplate="{StaticResource TaskListItemDataTemplate}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Hidden"                              
                          PreviewTouchDown="OnDragSourcePreviewTouchDown"
                          s:SurfaceDragDrop.Drop="TaskListBox_OnDropTargetDrop">
            <s:SurfaceListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Vertical" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=s:SurfaceListBox, AncestorLevel=1}, Path=ActualWidth}" />
                </ItemsPanelTemplate>
            </s:SurfaceListBox.ItemsPanel>
        </s:SurfaceListBox>
    </Grid>
</UserControl>
